<?php
/**
 * GeryEngine
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this release in the file LICENSE
 *
 * @copyright  Copyright (c) 2007 Arjen Brouwer
 * @license    New BSD License
 * @author     Arjen Brouwer
 */

/**
 * GeryEngine
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this release in the file LICENSE
 *
 * @copyright  Copyright (c) 2007 Arjen Brouwer
 * @license    New BSD License
 * @author     Arjen Brouwer
 */

class MethodProxy {

	var $className;
	var $methodName;
	
	function MethodProxy($className, $methodName) {
		$this->className = $className;
		$this->methodName = $methodName;
	}
	
	public function getClassName() {
		return $this->className;
	}
	
	function call($parameters) {
		return call_user_func_array(array($this->className, $this->methodName), $parameters);
	}
}

class MethodInvoker {
	
	/**
	 * The method to be invoked
	 *
	 * @var ReflectionMethod
	 */
	private $method;
	private $object;
	
	public function __construct(ReflectionMethod $method, $object = null) {
		$this->method = $method;
		$this->object = $object;
	}
	
	public function invoke($parameters) {
		return $this->method->invokeArgs($this->object, $parameters);
	}
	
	public static function newStatic(ReflectionMethod $method) {
		return new self($method);
	}
}
?>